package common.base;

import android.app.Application;
import android.content.Context;

import common.db.GreenDaoManager;

/**
 * Created by yangkuo02 on 2017/6/5.
 */

public class BaseApplication extends Application {

    /**
     * 本类实体对象
     */
    private static BaseApplication instance;

    @Override
    public void onCreate() {
        super.onCreate();
        GreenDaoManager.getInstance().init(getApplicationContext());
        instance = this;
    }


    /**
     * 获取本类实例
     *
     * @return 实例对象
     */
    public static final BaseApplication getInstance() {
        return instance;
    }

    /**
     * 获取应用程序上下文
     *
     * @return 应用程序上下文
     */
    public static final Context getContext() {
        final BaseApplication instance = getInstance();
        if (instance == null)
            throw new NullPointerException("");
        return instance.getApplicationContext();
    }


}
